import React from 'react';
import { Button, Modal } from 'antd';
import { inject, observer } from 'mobx-react';
import { WeaLocaleProvider ,WeaDialog,WeaInput,WeaFormItem,WeaError} from "ecCom"

const getLabel = WeaLocaleProvider.getLabel;


@observer
export default class SvaeTemplateDialog extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            date: ""
        }
    }
    componentDidMount() {

    }
    
    onCheck(){
        const { prjCardStore } = this.props;
        const {doSaveTemplet,templatename} = prjCardStore;
        if(templatename.trim()===""){
            this.refs.weaError.showError();
        }else{
            doSaveTemplet();
        }
    }

    render() {
        const { prjCardStore } = this.props;
        const {prjname,setVisiable,saveTemplateName,doSaveVisible } = prjCardStore;

        return <div>
            <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@rtq7vb`}
                title={getLabel(19468,'另存为模板')}
                visible={doSaveVisible}
                onCancel={() => { setVisiable(false) }}
                icon='icon-coms-project'
                iconBgcolor='#217346'
                style={{width: 380, height: 80}}
                buttons={ [
                    <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@vdw755@save`}  type="primary" onClick={()=>this.onCheck()}>{getLabel(86,"保存")}</Button>,
                    <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@ck17pe@cancel`}  type="primary" onClick={()=>setVisiable(false)}>{getLabel(201,"取消")}</Button>]}
            >   
                <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@h13bkr`}  label={getLabel('18151',"模板名称")}  labelCol={{span: 6}}   wrapperCol={{span: 12}} style={{top: 25, left: 40}}                        >
                    <WeaError ecId={`${this && this.props && this.props.ecId || ''}_WeaError@ddh1fk`} tipPosition='bottom'
                        ref='weaError'
                        error={getLabel('127697',"模板名称不能为空")}>
                        <WeaInput ecId={`${this && this.props && this.props.ecId || ''}_WeaInput@rmfvry`}
                            style={{width: 200}}
                            value={prjname}
                            viewAttr="3"
                            stringLength={90}
                            onChange={v =>{
                                saveTemplateName(v);
                            }}
                        />
                    </WeaError>
                </WeaFormItem>
            </WeaDialog>
        </div>
    }
}
